#include "csearchbutton.h"
#include <string>
using namespace std;

CSearchButton::CSearchButton(QWidget *parent)
    :QPushButton(parent)
{

    //this->setStyleSheet(QString::fromStdString(qss));

    this->setAttribute(Qt::WA_StyledBackground);
    this->setFixedHeight(40);
    normalStyle();

}


void CSearchButton::enterEvent(QEvent *event)
{

    this->setFixedHeight(40);
    string qss = R"(QPushButton{
            background-color:#148AFF;
            background-image:url(:/resources/search.png);
            background-repeat:no-repeart;
            background-position:left;
            background-origin:content;
            padding-left:10px;  //图片想左偏移
            text-align:right;   //文本的对齐方式
            padding-right:20px; //文本相对右边的偏移
            border-radius:20px;
            color:#FFFFFF;
            font-famil: \"Microsoft YaHei\";
            font-size: 20px;
    }
    )";

    this->setStyleSheet(QString::fromStdString(qss));
    this->setFixedWidth(130);
    this->setText("搜全网");
}

void CSearchButton::leaveEvent(QEvent *event)
{
   normalStyle();
}

void CSearchButton::normalStyle()
{

    this->setFixedHeight(40);
    string qss = R"(QPushButton{
            background-color:#148AFF;
            background-image:url(:/resources/search.png);
            background-repeat:no-repeart;
            background-position:center;
            border-radius:20px;
    }
    )";

   this->setStyleSheet(QString::fromStdString(qss));
    this->setFixedWidth(60);
    this->setText("");
}
